<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息展示</title>
</head>
<script>
    function updateMessage(id) {
        window.location.href="/modifyController/"+id;
    }
    function deleteConfirm(id) {

        let result = window.confirm("确定要删除吗？");
        if(result){
            window.location.href="/deleteController/"+id;
        }
    }
</script>

<body>

<table width="800" align="center" style="text-align: center">

    <div align="center">
        <a href="add.jsp">添加信息</a>
    </div>
    <div align="right">
        <a href="exitLoginController">退出登陆</a>
    </div>

</table>

<table width="800" align="center" border="1" style="text-align: center">
    <caption>学生信息</caption>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>地址</th>
        <th>编辑</th>
    </tr>
    <c:forEach items="${sessionScope.STUDENT_LIST}" var="student">
        <tr>
            <td>${student.id}</td>
            <td>${student.name}</td>
            <td>${student.gender}</td>
            <td>${student.age}</td>
            <td>${student.address}</td>
            <td colspan="2">
                <input type="button" value="修改" onclick="updateMessage(${student.id})" >
                &nbsp;&nbsp;||&nbsp;&nbsp;
                <input type="button" value="删除" onclick="deleteConfirm(${student.id})">
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
